package com.huoyun.common.dao;

import java.util.HashMap;
import java.util.Map;
import java.util.List;
import com.huoyun.base.dao.BaseDaoImpl;
import com.huoyun.common.bean.InviteCar;
import com.huoyun.common.dao.evt.QueryInviteCarModelEvt;
import com.huoyun.common.model.InviteCarModel;

public class InviteCarDaoImpl extends BaseDaoImpl<InviteCar> implements InviteCarDao {

	@Override
	public void saveInviteCar(InviteCar inviteCar) 
	{
		this.sqlSessionTemplate.insert("com.huoyun.common.dao.InviteCarDaoMapper.saveInviteCar", inviteCar);
	}

	@Override
	public void update(InviteCar inviteCar) 
	{
		this.sqlSessionTemplate.update("com.huoyun.common.dao.InviteCarDaoMapper.update", inviteCar);
	}
	
	@Override
	public InviteCar getInviteInfo(long goodsId, long carId)
	{
		Map<String, Object> dataMap = new HashMap<String, Object>();
		dataMap.put("goodsId", goodsId);
		dataMap.put("carId", carId);
		return this.sqlSessionTemplate.selectOne("com.huoyun.common.dao.InviteCarDaoMapper.getInviteInfoByGoodIdAndCarId", dataMap);
	}

	@Override
	public void delete(long inviteCarId) 
	{
		this.sqlSessionTemplate.delete("com.huoyun.common.dao.InviteCarDaoMapper.delete", inviteCarId);
	}

	@Override
	public InviteCarModel getInviteCarModelById(long inviteCarId) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectOne("com.huoyun.common.dao.InviteCarDaoMapper.getInviteCarModelById", inviteCarId);
	}

	@Override
	public List<InviteCarModel> getInviteCarModelListByUserId(long userId) {
		// TODO Auto-generated method stub
		return this.sqlSessionTemplate.selectList("com.huoyun.common.dao.InviteCarDaoMapper.getInviteCarModelListByUserId", userId);
	}
	@Override
	/**
	 * 获取指定用户的所有车辆的受邀列表 分页版
	 * @param userId
	 * @return 收到的车辆邀请详细列表
	 * @author 杨阳
	 */
	public List<InviteCarModel> queryInviteCarModelListByUserId(QueryInviteCarModelEvt queryInviteCarModelEvt){
	
		return this.sqlSessionTemplate.selectList("com.huoyun.common.dao.InviteCarDaoMapper.queryInviteCarModelListByUserId",queryInviteCarModelEvt);
	}
	/**
	 * 获取指定用户的所有车辆的受邀列表总数
	 * @param queryInviteCarModelEvt
	 * @return
	 * @author 杨阳
	 */
	public long getInviteCarModelListByUserIdCount(QueryInviteCarModelEvt queryInviteCarModelEvt){
		
		return this.sqlSessionTemplate.selectOne("com.huoyun.common.dao.InviteCarDaoMapper.getInviteCarModelListByUserIdCount",queryInviteCarModelEvt);
	}
}
